/**
 * 
 */
package ru.olympus.antonyhands.ao.server.item;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import ru.olympus.antonyhands.ao.server.db.IPersistentClass;
import ru.olympus.antonyhands.ao.shared.util.StringPair;

/**
 * @author AntonyHands
 * @since 14.02.2012
 */
public class ItemQuantityPairCollection implements IPersistentClass
{

    public static final String TAG_NAME = "item-quantity-pair-collection";

    private List<ItemQuantityPair> pairs = new ArrayList<ItemQuantityPair>();

    public ItemQuantityPairCollection()
    {
        // for the sake of persistence
    }

    public ItemQuantityPairCollection(Collection<ItemQuantityPair> newPairs)
    {
        pairs.addAll(newPairs);
    }

    @Override
    public String getTagName()
    {
        return TAG_NAME;
    }

    @Override
    public List<StringPair> getAttributes()
    {
        return new ArrayList<StringPair>();
    }

    @Override
    public void setAttributes(List<StringPair> attributes)
    {
    }

    @Override
    public Collection<? extends IPersistentClass> getPersistentChildren()
    {
        return pairs;
    }

    @Override
    public void setPersistentChildren(List<IPersistentClass> persistentChildren)
    {
        for (IPersistentClass persistent : persistentChildren)
            if (persistent instanceof ItemQuantityPair)
                pairs.add((ItemQuantityPair)persistent);
    }

    public List<ItemQuantityPair> listPairs()
    {
        return pairs;
    }
}